package com.feihong.yw189.adapter.Kuandai;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.feihong.yw189.R;
import com.feihong.yw189.activity.kaika.KaiKaActivity;
import com.feihong.yw189.model.Kaika.ZuoJiModel;
import com.holenzhou.pullrecyclerview.BaseRecyclerAdapter;
import com.holenzhou.pullrecyclerview.BaseViewHolder;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.feihong.yw189.activity.kuandai.ZuoJiActivity.SELECT_FIXPHONE_FULL_NUM_KEY;
import static com.feihong.yw189.activity.kuandai.ZuoJiActivity.SELECT_FIXPHONE_NUM_ID_KEY;
import static com.feihong.yw189.activity.kuandai.ZuoJiActivity.SELECT_FIXPHONE_NUM_KEY;


/**
 * Created by PVer on 2018/1/5.
 */

public class ZuoJiAdapter extends BaseRecyclerAdapter<ZuoJiModel.DataBean.ListBean> {

    Activity mcontext;
    Map<String, String> map = new HashMap<>();

    public ZuoJiAdapter(Context context, int layoutResId, List<ZuoJiModel.DataBean.ListBean> data) {
        super(context, layoutResId, data);
        mcontext = (Activity) context;

    }

    @Override
    public void convert(final BaseViewHolder holder, final ZuoJiModel.DataBean.ListBean item) {

        holder.setText(R.id.tv_telphone, item.getBOROUGH() + "-" + item.getNUMBER());
        if (!TextUtils.isEmpty(item.getRegion())) {
            holder.setText(R.id.tv_dianxin, item.getRegion());
        }

        ImageView imageView = (ImageView) holder.getView().findViewById(R.id.iv_select);
        imageView.setTag(holder.getAdapterPosition());
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int pos = -1;
                try {
                    pos = Integer.parseInt(v.getTag().toString());
                } catch (Exception ex) {
                }
                if (mFixOnItemClickListener != null) {
                    mFixOnItemClickListener.onItemClick(getItem(pos));
                }

            }
        });
    }

    private FixOnItemClickListener mFixOnItemClickListener;

    public void setOnItemClick(FixOnItemClickListener fixOnItemClickListener) {
        mFixOnItemClickListener = fixOnItemClickListener;
    }

    public interface FixOnItemClickListener {
        void onItemClick(ZuoJiModel.DataBean.ListBean listBean);
    }

}
